package com.zaofan.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zaofan.bean.GoodsType;
import com.zaofan.dao.GoodsTypeDao;

public class GoodsTypeService {

	private GoodsTypeDao typeDao = new GoodsTypeDao();

	public void delete(GoodsType type) {
		typeDao.del(type);
	}

	public void add(GoodsType type) {
		typeDao.add(type);
	}

	public void update(GoodsType type) {
		typeDao.update(type);
	}

	public List<GoodsType> findAll(Map<String, Object> params) {
		List<GoodsType> data = typeDao.findAll(params);
		if (data == null) {
			data = new ArrayList<>();
		}
		return data;
	}

	public Long count(Map<String, Object> params) {
		return typeDao.count(params);
	}

	public GoodsType findById(Integer id) {
		Map<String, Object> params = new HashMap<>();
		params.put("id", id);
		return typeDao.findOne(params);
	}

	public List<GoodsType> getTopThreeType() {
		Map<String, Object> params = new HashMap<>();
		params.put("order", " by sort asc");
		params.put("begin", "0");
		params.put("end", "3");
		return findAll(params);
	}

}
